from datetime import datetime
from tools.http.req import send_json_request
from tools.log import logger

def work(gloabal_conf,self_conf):
    template_format=self_conf["power"]["template"] # DICT
    template_format["updateTime"] = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
    res = send_json_request(
        url=self_conf["power"]["api"],
        payload=template_format,
    )
    if res["success"]:
        logger.info("{box} 上传电源成功!".format(box=gloabal_conf["box"]["id"]))
    else:
        logger.warning("{box} 上传电源失败!".format(box=gloabal_conf["box"]["id"])) 
